package cn.tedu.charging.user.controller;

import cn.tedu.chaging.common.web.JsonResult;
import cn.tedu.charging.user.service.IChargingUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class WeiXinLoginController {

    @Autowired
    private IChargingUserInfoService chargingUserInfoService;



    /**
     * 手机调用本接口
     * code:临时token
     * nickname:呢称
     */
    @GetMapping("/wx/login")
    public JsonResult<Integer> wxLogin(@RequestParam("code") String code, String nickName) throws Throwable {

        Integer userId = chargingUserInfoService.wxLogin(code, nickName);

        return JsonResult.ok(userId);

    }
}
